package cc.vv.lkimagecomponent2.initplugin;

import android.content.Context;
import android.widget.ImageView;

import cc.vv.lkimagecomponent2.lib.LoadFactory;
import cc.vv.lklibrary.log.LogOperate;

/**
 * @author dupeng dupeng@vv.cc
 * @date 2018/5/3
 */

public class InitPlugin {
    private static InitPlugin instance;

    public InitConfig mConfig;

    public static InitPlugin getInstance() {
        if (instance == null) {
            synchronized (InitPlugin.class) {
                if (instance == null) {
                    instance = new InitPlugin();
                }
            }
        }
        return instance;
    }

    /**
     * 初始化
     *
     * @param context
     * @return
     */
    public InitConfig.InitBuilder init(Context context) {
        if (context == null) {
            LogOperate.e("LKImage context 为空！使用此库，必须提前调用init()方法,传入applicationContext!");
            return null;
        }
        return new InitConfig.InitBuilder(context);
    }

    /**
     * 插件调用外部的方法
     *
     * @param config
     */
    public void build(InitConfig config) {
        this.mConfig = config;
        LoadFactory.getInstance().getEngine().init(config);
    }

}
